package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	comment := "Test contents leak."
	basicReader := strings.NewReader(comment)
	reader := bufio.NewReaderSize(basicReader, 30)

	bytes, err := reader.Peek(5)
	if err != nil {
		fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
	}
	fmt.Printf("Peek读取(%d): %q\n", len(bytes), bytes)

	// 扩张返回的字节切片
	bytes = bytes[:cap(bytes)]
	fmt.Printf("利用内容泄露获取到了所有的内容: %q\n", bytes)
}
